/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-05-31     Dell       the first version
 */
#ifndef APPLICATIONS_DISTANCE_H_
#define APPLICATIONS_DISTANCE_H_


#include <rtthread.h>
#include <board.h>
#include <drv_common.h>
#include <rtdevice.h>

#define DISTANCE_HWTIM_DEVICE_NAME "timer3"
#define DISTANCE_ECHO_PIN 16       // ECHO 对应的Pin脚  PB0
#define DISTANCE_TRIG_PIN 17       // Trig 对应的Pin脚  PB1
#define DISTANCE_DETECT_FREQ 10000  // 定时器计数频率


/***
 * 初始化测距模块
 */
void distance_init();


/***
 * 定时器回调函数，用于测量距离
 *
 */
rt_err_t distance_detect(rt_device_t dev, rt_size_t size);


/**
 * 测量距离的线程
 */
void distance_timer_start(void *parameter);


#endif /* APPLICATIONS_DISTANCE_H_ */
